﻿@page "/tree/tree"
@using Blazor.ECharts.Options
@using Blazor.ECharts.Options.Enum
@using Blazor.ECharts.Options.Series
@using T = Blazor.ECharts.Options.Series.Tree

<div class="chart-container">
    <ETree Option="@Option1" Class="chart-fill"></ETree>
</div>

@code{
    private EChartsOption<T.Tree> Option1;

    protected override void OnInitialized()
    {
        base.OnInitialized();

        List<NoteDataItem> data = new()
        {
            new()
            {
                Name = "A",
                Children = new()
                {
                    new()
                    {
                        Name = "A1",
                        Children = new()
                        {
                            new()
                            {
                                Name = "A11"
                            },
                            new()
                            {
                                Name = "A12",
                                Value = 3322
                            }
                        }

                    },
                    new()
                    {
                        Name = "A2",
                        Children = new()
                        {
                            new()
                            {
                                Name = "A21",
                                Value = 8833
                            },
                            new()
                            {
                                Name = "A22",
                                Value = 1732
                            },
                            new()
                            {
                                Name = "A23",
                                Value = 3623
                            }
                        }
                    },
                    new()
                    {
                        Name = "A3",
                        Children = new()
                        {
                            new() { Name = "A31", Value = 4116 }
                        }
                    }
                }
            }
        };

        Option1 = new()
        {
            Tooltip = new()
            {
                Trigger = TooltipTrigger.Item
            },
            Legend = new()
            {
                Top = "2%",
                Left = "3%",
                Data = new[] { new { Name = "tree1", Icon = "rectangle" } }
            },
            Series = new()
            {
                new T.Tree()
                {
                    Name = "tree1",
                    Data = data,
                    Top = "5%",
                    Left = "7%",
                    Bottom = "2%",
                    Right = "20%",
                    SymbolSize = 20,
                    Label = new()
                    {
                        Position = LabelPosition.Top,
                        Align = Align2.Left
                    },
                    Leaves = new()
                    {
                        Label = new()
                        {
                            Position = LabelPosition.Right,
                            Align = Align2.Left
                        }
                    }
                }
            }
        };
    }
}